//
//  DSNetWorkShareView.m
//  DaBaiService
//
//  Created by NICOLA on 16/4/19.
//  Copyright © 2016年 Mac-Mini-KingVision. All rights reserved.
//

#import "DSNetWorkShareView.h"
#import "DSNetWorkShareView.h"
#import "PlatformMacro.h"

@interface DSNetWorkShareView ()

@end

@implementation DSNetWorkShareView

- (instancetype)init
{
    self = [super init];
    if (self) {
//        self.layer.cornerRadius = 5;
//        self.layer.masksToBounds = YES;
        self.backgroundColor = [self colorWithRGB:0xf5f5f5];
        [self setupSubViews];
    }
    return self;
}

- (UIColor *)colorWithRGB:(uint32_t)rgbValue {
    return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0f
                           green:((rgbValue & 0xFF00) >> 8) / 255.0f
                            blue:(rgbValue & 0xFF) / 255.0f
                           alpha:1];
}

- (void)setupSubViews {
    
    
    UILabel *lable1 = [[UILabel alloc] init];
    lable1.textColor = [self colorWithRGB:0x333333];
    lable1.text = @"分享到";
    //    lable1.font = [UIFont fontWithName:@"Thonburi-Bold" size:17];
    //lable1.font = [UIFont fontWithName:nil size:17];
    lable1.font = [UIFont systemFontOfSize:17];
    [lable1 sizeToFit];
    self.lable1 = lable1;
    [self addSubview:lable1];
    lable1.frame = CGRectMake(15, 0, ScreenWidth,50);
    
    UIButton *WxBtn = [[UIButton alloc] init];
    [WxBtn setImage:[UIImage imageNamed:@"weixin"]forState:UIControlStateNormal];
    [WxBtn addTarget:self action:@selector(chooseWx) forControlEvents:UIControlEventTouchUpInside];
    self.WxBtn = WxBtn;
    [self addSubview:WxBtn];
    WxBtn.frame = CGRectMake(ScreenWidth/4 - 23,60,50, 50);
    
    UIButton *pyqBtn = [[UIButton alloc] init];
    [pyqBtn setImage:[UIImage imageNamed:@"pyq"]forState:UIControlStateNormal];
    [pyqBtn addTarget:self action:@selector(choosePyq) forControlEvents:UIControlEventTouchUpInside];
    self.PyqBtn = pyqBtn;
    [self addSubview:pyqBtn];
    pyqBtn.frame = CGRectMake((ScreenWidth/4 * 3 - 23), 60, 50, 50);
    
    UILabel *lable2 = [[UILabel alloc] init];
    lable2.textColor = [self colorWithRGB:0x666666];
    lable2.text = @"微信";
    lable2.font = [UIFont fontWithName:@"Thonburi" size:15];
    [lable2 sizeToFit];
    self.lable2 = lable2;
    [self addSubview:lable2];
    lable2.frame = CGRectMake((ScreenWidth/4 - 14),103,50, 50);
    
    UILabel *lable3 = [[UILabel alloc] init];
    lable3.textColor = [self colorWithRGB:0x666666];
    lable3.text = @"朋友圈";
    lable3.font = [UIFont fontWithName:@"Thonburi" size:15];
    [lable3 sizeToFit];
    self.lable3 = lable3;
    [self addSubview:lable3];
    lable3.frame = CGRectMake((ScreenWidth/4 * 3 - 20), 103, 50, 50);
    self.frame = CGRectMake(0, ScreenHeight - 340, ScreenWidth, 170);
    
    
}

//点击对应的按钮后,利用通知让DSTYAlertController
-(void)chooseWx
{
    if (self.leftBtnBlock) {
        self.leftBtnBlock();
    }

//    NSLog(@"%@",self.netWorkTitle2);
//    NSDictionary *dic1 =[[NSDictionary alloc]initWithObjectsAndKeys:self.ShareConent2,@"content",self.netWorkTitle2,@"title",self.imageUrl2,@"image",self.netWorkUrl2,@"url",nil];
//        NSNotification *noti1 = [NSNotification notificationWithName:@"shareWx"object:nil userInfo:dic1];
//    [[NSNotificationCenter defaultCenter] postNotification:noti1];
    
}
-(void)choosePyq
{
    
    if (self.rightBtnBlock) {
        self.rightBtnBlock();
    }

    NSDictionary *dic2 =[[NSDictionary alloc]initWithObjectsAndKeys:self.ShareConent2,@"content",self.netWorkTitle2,@"title",self.imageUrl2,@"image",self.netWorkUrl2,@"url",nil];

    NSNotification *noti2 = [NSNotification notificationWithName:@"sharePyq"object:nil userInfo:dic2];
    
    [[NSNotificationCenter defaultCenter] postNotification:noti2];
    
}


@end


